package ar.fi.uba.fallas2;

import javax.servlet.http.HttpServletRequest;

public class SessionHandler {

	private static final String QUESTION_ANSWER_MANAGER = "QuestionAnswerManager";

	public static QuestionAnswerManager getQAM(HttpServletRequest request) {
		QuestionAnswerManager qam = (QuestionAnswerManager)request.getSession().getAttribute(QUESTION_ANSWER_MANAGER);
	    if (qam==null) {
	    	qam = new QAMFactory().create();
	    	request.getSession().setAttribute(QUESTION_ANSWER_MANAGER,qam);
	    }
	    return qam;
	}

	public static boolean hasQAM(HttpServletRequest request) {
		return request.getSession().getAttribute(QUESTION_ANSWER_MANAGER)!=null;
	}
	
}
